﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Itau.IM.Common.Mainframe.Book
{
    [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
    public sealed class BookCollectionFieldAttribute : BookFieldBaseAttribute
    {
        public BookFieldBaseAttribute ItemAttribute
        {
            get;
            set;
        }
        public string DefaultItemValue
        {
            get;
            set;
        }
        public int Length
        {
            get;
            set;
        }
        public Type ItemType
        {
            get;
            set;
        }
        public bool InsertListCount
        {
            get;
            set;
        }
        public string ListCountFormat
        {
            get;
            set;
        }
        public Type MaxItensType
        {
            get;
            set;
        }
        public string MaxItensProperty
        {
            get;
            set;
        }

        public BookCollectionFieldAttribute(int StartIndex, Type ItemAttribute, Type ItemType, int Length, string DefaultItemValue)
            : base(StartIndex)
        {
            this.Length = Length;
            this.ItemAttribute = (BookFieldBaseAttribute)Assembly.GetAssembly(ItemAttribute).CreateInstance(ItemAttribute.FullName);
            this.DefaultItemValue = DefaultItemValue;
            this.ItemType = ItemType;
        }

        public BookCollectionFieldAttribute(int StartIndex, Type ItemAttribute, Type ItemType, int Length, string DefaultItemValue, bool InsertListCount, string ListCountFormat)
            : this(StartIndex, ItemAttribute, ItemType, Length, DefaultItemValue)
        {
            this.InsertListCount = InsertListCount;
            this.ListCountFormat = ListCountFormat;
        }

        public BookCollectionFieldAttribute(int StartIndex, Type ItemAttribute, Type ItemType, Type maxItensType, string maxItensProperty, string DefaultItemValue)
            : this(StartIndex, ItemAttribute, ItemType, 0, DefaultItemValue)
        {
            this.MaxItensType = maxItensType;
            this.MaxItensProperty = maxItensProperty;
        }

        public BookCollectionFieldAttribute() : base(0)
        {
        }
    }
}
